import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VisitorVO, VisitorForm, VisitorQuery } from '@/api/nursing/visitor/types';

/**
 * 查询访客记录列表
 * @param query
 * @returns {*}
 */

export const listVisitor = (query?: VisitorQuery): AxiosPromise<VisitorVO[]> => {
  return request({
    url: '/nursing/visitor/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询访客记录详细
 * @param visitorId
 */
export const getVisitor = (visitorId: string | number): AxiosPromise<VisitorVO> => {
  return request({
    url: '/nursing/visitor/' + visitorId,
    method: 'get'
  });
};

/**
 * 新增访客记录
 * @param data
 */
export const addVisitor = (data: VisitorForm) => {
  return request({
    url: '/nursing/visitor',
    method: 'post',
    data: data
  });
};

/**
 * 修改访客记录
 * @param data
 */
export const updateVisitor = (data: VisitorForm) => {
  return request({
    url: '/nursing/visitor',
    method: 'put',
    data: data
  });
};

/**
 * 删除访客记录
 * @param visitorId
 */
export const delVisitor = (visitorId: string | number | Array<string | number>) => {
  return request({
    url: '/nursing/visitor/' + visitorId,
    method: 'delete'
  });
};
